using System.Collections.Generic;

namespace DesignPattern.Structural.Flyweight
{
    public class SharpFactory
    {
        private static Dictionary<string, ISharp> _circles = new Dictionary<string, ISharp>();

        public static ISharp GetCircle(string color)
        {
            _circles.TryGetValue(color, out var circle);

            if (circle == null)
            {
                circle = new Circle(color);
                _circles.TryAdd(color, circle);
                System.Console.WriteLine($"Created circle of color: {color}");
            }

            return circle;
        }
    }
}